#include <bits/stdc++.h>
using namespace std;

//(a % p) * (b % p) = (a * b) % p;
typedef long long ll;
ll a, b, p;
int qucikpow(ll x, ll n, ll mod)
{
    int res = 1;
    while (n)
    {
        if (n & 1)
        {
            res = (res * x) % mod;
        }
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;

}
int main()
{
    scanf("%lld%lld%lld", &a, &b, &p);
    int ans = qucikpow(a, b, p);

    printf("%lld^%lld mod %lld=%lld", a, b, p, ans);
    return 0;
}